import http from '@/utils/http'

const BASE_URL = '/testing/report'

export interface ReportResp {
  id: string
  projectId: string
  caseId: string
  type: string
  name: string
  executeState: string
  summary: string
  startTime: string
  endTime: string
  expandTime: string
  quantity: string
  passQuantity: string
  failQuantity: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ReportDetailResp {
  id: string
  projectId: string
  caseId: string
  type: string
  name: string
  executeState: string
  summary: string
  startTime: string
  endTime: string
  expandTime: string
  quantity: string
  passQuantity: string
  failQuantity: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ReportQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface ReportPageQuery extends ReportQuery, PageQuery {}

/** @desc 查询测试报告列表 */
export function listReport(query: ReportPageQuery) {
  return http.get<PageRes<ReportResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询测试报告详情 */
export function getReport(id: string) {
  return http.get<ReportDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增测试报告 */
export function addReport(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改测试报告 */
export function updateReport(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除测试报告 */
export function deleteReport(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出测试报告 */
export function exportReport(query: ReportQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
